package tiantian_ssm;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import edu.gdut.tiantian.dao.ProductDao;
import edu.gdut.tiantian.entity.Product;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:bean.xml")
public class ProductTester {
	
	@Autowired
	private ProductDao productDao;
	
	
	@Test
	public void testFindById() {
		Product product = productDao.findById("8e483be6930411e9886e05869249b5b2");
		System.out.println(product);
	}
	
	@Test
	public void testFindByCondition() {
		Map<String, String> condition = new HashMap<>();
		condition.put("lowPrice","100");
		condition.put("highPrice","7000");
		List<Product> products = productDao.findByCondition(condition);
		for(Product pro : products) {
			System.out.println(pro);
		}
	}
	
	}
